<?php

namespace Weixin\Controller;
use Common\Controller\WeixinbaseController;

class AdminController extends WeixinbaseController
{
    
    public function index()
    {
        $weiHostUrl ="https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=".$this->access_token;
        
        $weiMenuUrl ="https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN";

        $menu=array(
            "button"=>array(
                array(
                    "type"=>"view",
                    "name"=>"菜单一",
                    "url"=>"http://www.baidu.com"
                ),
                array(
                    "name"=>"菜单二",
                    "sub_button"=>array(
                        array(
                            "type"=>"view",
                            "name"=>"搜索",
                            "url"=>"http://www.soso.com"
                        ),
                        array(
                            "type"=>"view",
                            "name"=>"视频",
                            "url"=>"http://v.qq.com"
                        ),
                        array(
                            "type"=>"click",
                            "name"=>"赞一下我们",
                            "key"=>"V1001_GOOD"
                        )
                    )
                ),
                array(
                    "type"=>"view",
                    "name"=>"菜单三",
                    "url"=>"http://m.sem123.com"
                )
            ),
        );

        $post_data =json_encode($menu,JSON_UNESCAPED_UNICODE);

        debug($post_data,false,false);

        $result =post_weixinApi($weiMenuUrl,$post_data,$this->access_token);

        print_r($result);
        
    }

}